package com.org.gsc.zuixindemo;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;

/**
 * Created by qundui on 2017/10/23.
 */
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.VH> {
    private Context mContext;
    private String[] str;

    public MyAdapter(Context context, String[] str) {
        mContext = context;
        this.str = str;
    }

    @Override
    public VH onCreateViewHolder(ViewGroup parent, int viewType) {
        return new VH(LayoutInflater.from(mContext).inflate(R.layout.rv_items,parent,false));
    }
    @Override
    public void onBindViewHolder(VH holder, int position) {
        Picasso.with(mContext).load(str[position]).into(holder.mImageView);
    }
    @Override
    public int getItemCount() {
        return str.length;
    }

    public class VH extends RecyclerView.ViewHolder {
        ImageView mImageView;
        public VH(View itemView) {
            super(itemView);
            mImageView=itemView.findViewById(R.id.iv);
        }
    }
}
